using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PACKETPARSERMAX20.CORE;

namespace PACKETPARSERMAX20.CORE.DEFINITIONS
{
    public class SMSG_QUEST_POI_QUERY_RESPONSE_DEF : DefinitionBase
    {
        /// <summary>
        /// Generated   3/10/2010 7:06:58 PM
        /// Build       11403
        /// Opcode      484
        /// </summary>
        /// <returns></returns>
        public override bool Process()
        {
            ResetPosition();
            var count = ReadUInt32(); // quest count
            for (int i = 0; i < count; i++)
            {
                var questid = ReadUInt32(); // quest ID
                var poicount = ReadUInt32(); // POI count

                for (int j = 0; j < poicount; j++)
                {
                    var index = ReadUInt32();           // POI index

                    quest_poi tquest_poi = new quest_poi();
                    tquest_poi.questid = questid;
                    tquest_poi.objindex = ReadInt32();   // objective index
                    tquest_poi.mapid = ReadUInt32();            // mapid
                    tquest_poi.mapareaid = ReadUInt32();              // unknown
                    tquest_poi.floorid = (byte)ReadUInt32();              // unknown
                    tquest_poi.unk3 = ReadUInt32();             // unknown
                    tquest_poi.unk4 = ReadUInt32();              // unknown

                    var poipointscount = ReadUInt32();     // POI points count
                    
                    for (int k = 0; k < poipointscount; k++)
                    {
                        quest_poi_points tquest_poi_points = new quest_poi_points();
                        tquest_poi_points.questid = questid;
                        tquest_poi_points.x = ReadInt32();             // POI point x
                        tquest_poi_points.y = ReadInt32();             // POI point y
                        GlobalCache.AddQuestPOIPointsSum(tquest_poi_points, ClientBuild);
                    }
                    GlobalCache.AddQuestPOISum(tquest_poi, ClientBuild);
                }
            }

            return Validate();
        }
    }
}